package com.zhuss.core.processor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zhuss.core.db.dao.ext.FileDao;
import com.zhuss.exception.OceanException;
import com.zhuss.exception.ExceptionCode;


/**
 * 查询文件 processor
 * @Author: zhushanshuo
 * @Date: 2020/02/26 21:55
 */
@Component("fileRead")
public class FileRead {
	
	@Autowired
	private FileDao fileDao;
	
	/**
	 * 文件详情
	 * @return
	 * @throws OceanException
	 */
	public Object listAll() throws OceanException {
		Object result = fileDao.listAll();
		if (result == null) {
			throw new OceanException(ExceptionCode.数据不存在);
		}
		return result;
	}
	
	/**
	 * 文件详情
	 * @param key
	 * @return
	 * @throws OceanException
	 */
	public Object getByKey(String key) throws OceanException {
		Object result = fileDao.getByKey(key);
		if (result == null) {
			throw new OceanException(ExceptionCode.数据不存在);
		}
		return result;
	}
	
	/**
	 * 文件详情
	 * @param fileId
	 * @return
	 * @throws OceanException
	 */
	public Object detail(Long fileId) throws OceanException {
		Object result = fileDao.detail(fileId);
		if (result == null) {
			throw new OceanException(ExceptionCode.数据不存在);
		}
		return result;
	}


}
